package cn.qvtu.game.util;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

public class StaticValue {
    // 获取项目根目录
    public static final String ImagePath = "res/";
    // 背景图片
    public static BufferedImage bg01 = null;
    public static BufferedImage bg02 = null;
    public static BufferedImage bg03 = null;
    public static BufferedImage bg04 = null;
    // 人物图片集合
    public static List<BufferedImage> LeftPersonImages = new ArrayList<>();
    public static List<BufferedImage> RightPersonImages = new ArrayList<>();
    // 敌人图片集合
    public static List<BufferedImage> LeftEnemyImages = new ArrayList<>();
    public static List<BufferedImage> RightEnemyImages = new ArrayList<>();

    // 获取图片资源
    static {
        try {
            // 获取背景
            bg01 = ImageIO.read(new File(ImagePath + "background/bg01.png"));
            bg02 = ImageIO.read(new File(ImagePath + "background/bg02.png"));
            bg03 = ImageIO.read(new File(ImagePath + "background/bg03.png"));
            bg04 = ImageIO.read(new File(ImagePath + "background/bg04.png"));
            // 获取人物图片
            for (int i = 1; i <= 14; i++) {
                // 数据格式化
                DecimalFormat df = new DecimalFormat("00");
                String num = df.format(i);
                // 添加人物图片到集合中
                LeftPersonImages.add(ImageIO.read(new File(ImagePath + "person/left/" + num + ".png")));
                RightPersonImages.add(ImageIO.read(new File(ImagePath + "person/right/" + num + ".png")));
            }
            // 获取敌人图片
            for (int i = 0; i <= 5; i++) {
                // 添加敌人图片到集合中
                LeftEnemyImages.add(ImageIO.read(new File(ImagePath + "enemy/left/141_move_" + i + ".png")));
                RightEnemyImages.add(ImageIO.read(new File(ImagePath + "enemy/right/141_move_" + i + ".png")));
            }
            for (int i = 0; i <= 7; i++) {
                // 添加敌人图片到集合中
                LeftEnemyImages.add(ImageIO.read(new File(ImagePath + "enemy/left/141_skill_1104_" + i + ".png")));
                RightEnemyImages.add(ImageIO.read(new File(ImagePath + "enemy/right/141_skill_1104_" + i + ".png")));
            }
            for (int i = 0; i <= 5; i++) {
                // 添加敌人图片到集合中
                LeftEnemyImages.add(ImageIO.read(new File(ImagePath + "enemy/left/141_stand_"+i+".png")));
                RightEnemyImages.add(ImageIO.read(new File(ImagePath + "enemy/right/141_stand_"+i+".png")));
            }
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }
}
